<template>
	<!-- 优惠券状态标签栏 -->
	<view class="tab-bar">
		<view class="tab-item" :class="{ active: currentTab === 'toUse' }" @click="changeTab('toUse')">
			待使用({{ toUseCount }})
		</view>
		<view class="tab-item" :class="{ active: currentTab === 'used' }" @click="changeTab('used')">
			已使用({{ usedCount }})
		</view>
		<view class="tab-item" :class="{ active: currentTab === 'expired' }" @click="changeTab('expired')">
			已失效({{ expiredCount }})
		</view>
	</view>
	<view class="container">
		<!-- 优惠券列表 -->
		<scroll-view scroll-y class="coupon-list">
			<!-- <view class="coupon-item" v-for="(coupon, index) in currentCoupons" :key="index">
				<view class="left">
					<view class="price">
						<text class="symbol">¥</text>
						<text>{{ coupon.price }}</text>
					</view>
					<view class="type">满减券</view>
				</view>
				<view class="middle">
					<view class="name">{{ coupon.name }}</view>
					<view class="detail">
						<text>{{ coupon.price }}元抵用券</text>
						<text>{{ coupon.validityPeriod }}</text>
					</view>
				</view>
				<view class="right">
					<button type="warn" size="mini" @click="useCoupon(coupon)">去使用</button>
				</view>
			</view> -->
		</scroll-view>
		<view class="content">
			<!-- v-if="isEmpty" -->
			<view class="empty">
				<image src="/static/empty-icon.png" mode="widthFix"></image>
				<text>暂无数据，如有问题，请联系客服</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				currentTab: 'toUse',
				toUseCount: 0,
				usedCount: 0,
				expiredCount: 0,
				coupons: [{
						price: 10,
						name: '邀约奖励券',
						validityPeriod: '2024-07-24 10:32:19有效期内可用',
						status: 'toUse'
					},
					{
						price: 1,
						name: '邀约奖励券',
						validityPeriod: '2024-07-24 10:32:19有效期内可用',
						status: 'toUse'
					},
					{
						price: 5,
						name: '邀约奖励券',
						validityPeriod: '2024-07-24 10:32:19有效期内可用',
						status: 'toUse'
					},
					{
						price: 6,
						name: '邀约奖励券',
						validityPeriod: '2024-07-24 10:32:19有效期内可用',
						status: 'used'
					},
					{
						price: 7,
						name: '邀约奖励券',
						validityPeriod: '2024-07-24 10:32:19有效期内可用',
						status: 'expired'
					},
					{
						price: 9,
						name: '邀约奖励券',
						validityPeriod: '2024-07-24 10:32:19有效期内可用',
						status: 'toUse'
					}
				]
			};
		},
		computed: {
			currentCoupons() {
				return this.coupons.filter(coupon => coupon.status === this.currentTab);
			}
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			changeTab(tab) {
				this.currentTab = tab;
			},
			useCoupon(coupon) {
				// 处理使用优惠券
				console.log(`使用优惠券：${coupon.name}`);
			}
		}
	};
</script>

<style lang="scss">
	.tab-bar {
		display: flex;
		justify-content: space-around;
		background-color: #fff;
		border-bottom: 1rpx solid #eee;
		position: static;
		top: 0;

		.tab-item {
			width: 140rpx;
			text-align: center;
			padding: 20rpx 0;
			font-size: 28rpx;

			&.active {
				color: #ff4500;
				border-bottom: 4rpx solid #ff4500;
			}
		}
	}

	.container {
		background-color: #f5f5f5;
		height: 100vh;

		.coupon-list {
			padding-top: 20rpx;

			.coupon-item {
				display: flex;
				align-items: center;
				border-radius: 10rpx;
				margin-bottom: 20rpx;
				padding: 20rpx;
				border: 20rpx solid #f95457;

				.left {
					width: 120rpx;
					display: flex;
					flex-direction: column;
					align-items: center;

					.price {
						font-size: 36rpx;
						color: #fb605a;
						font-weight: bold;

						.symbol {
							font-size: 24rpx;
						}
					}

					.type {
						font-size: 20rpx;
						color: #fb605a;
						background-color: rgba(255, 255, 255, 0.2);
						padding: 5rpx 10rpx;
						border-radius: 5rpx;
					}
				}

				.middle {
					flex: 1;
					margin-left: 20rpx;

					.name {
						font-size: 28rpx;
						font-weight: bold;
						color: #333;
					}

					.detail {
						font-size: 24rpx;
						color: #666;
						margin-top: 10rpx;
					}
				}

				.right {
					width: 120rpx;
					text-align: right;

					button {
						padding: 10rpx 20rpx;
						border-radius: 20rpx;
					}
				}
			}
		}

		.content {
			flex: 1;
			padding: 20rpx;

			.empty {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);

				image {
					width: 200rpx;
					margin-bottom: 20rpx;

				}

				text {
					font-size: 24rpx;
				}
			}
		}
	}
</style>